<template>
  <div
    :class="['avue-logo', { isActive: nowTagValue == '/wel/index' }]"
    @click="goto"
  >
    <i class="myfont icon-home"></i>
    <span>
      首页
    </span>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { isURL } from '@/util/validate'
export default {
  name: 'logo',
  data () {
    return {}
  },
  created () {},

  computed: {
    ...mapGetters(['website', 'keyCollapse', 'tag', 'menu']),
    nowTagValue: function () {
      return this.$router.$avueRouter.getValue(this.$route)
    }
  },
  methods: {
    goto () {
      this.$store.commit('SET_CURRENT_SIDE', '/wel/index')
      let tag = this.website.fistPage
      if (this.screen <= 1) this.$store.commit('SET_COLLAPSE')
      if (this.validIsOpen(tag)) {
        window.open(tag[this.pathKey])
      } else {
        this.$router.$avueRouter.group = tag.group
        this.$router.$avueRouter.meta = tag.meta
        this.$router.push({
          path: this.$router.$avueRouter.getPath(
            {
              name: tag.label,
              src: tag.value
            },
            tag.meta
          ),
          query: tag.query
        })
      }
      let list = []
      this.menu.forEach(item => {
        list.push(...item.children)
      })
      this.$store.commit('SET_TAB_LIST', list)
    },
    validIsOpen (item) {
      if (item[this.isOpenKey] === 2 && isURL(item[this.pathKey])) {
        return true
      }
    }
  }
}
</script>

<style lang="scss">
.fade-leave-active {
  transition: opacity 0.2s;
}
.fade-enter-active {
  transition: opacity 2.5s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
.avue-logo {
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 70px;
  line-height: 64px;
  background-color: #fff;
  font-size: 20px;
  overflow: hidden;
  box-sizing: border-box;
  color: #11212f;
  z-index: 1024;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: left;
  cursor: pointer;
  padding: 10px 0 6px 22px;
  &:hover {
    i,
    span {
      color: #1c7df0;
    }
  }
  i {
    font-size: 30px;
    color: #999;
    height: 30px;
    line-height: 30px;
  }
  span {
    font-size: 16px;
    color: rgba(49, 58, 70, 0.8);
    text-align: center;
    line-height: 30px;
    padding-left: 10px;
  }

  &_title {
    display: block;
    text-align: center;
    font-weight: 300;
    font-size: 20px;
  }
  &_subtitle {
    display: block;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
  }
}
.isActive {
  i,
  span {
    color: #1c7df0;
  }
}
</style>
